'use client'
import { usePathname } from 'next/navigation'
import { Header } from '@/app/components/header'
import { Sidebar } from '@/app/components/sidebar'
// import { useMemo } from 'react'

// 定义布局类型
type LayoutType = 'default' | 'topNav' | 'withSidebar'

// const sidebarPaths = ['/home', '/graphic', '/movie', '/todoing', '/mysource']
// 路径到布局类型的映射
const PATH_LAYOUTS: Record<string, LayoutType> = {
  '/home': 'withSidebar',
  '/graphic': 'withSidebar',
  '/movie': 'withSidebar',
  '/todoing': 'withSidebar',
  '/mysource': 'withSidebar',
  // 添加更多路径映射
}

export function LayoutWrapper({ children }: { children: React.ReactNode }) {
  const pathname = usePathname()
  // const layoutType = useMemo(() => {
  //   const isPathWithSidebar =
  //     pathname === '/' || sidebarPaths.some((path) => pathname.startsWith(path))
  //   return isPathWithSidebar ? 'withSidebar' : 'default'
  // }, [pathname])

  const layoutType = PATH_LAYOUTS[pathname] || 'default'

  const renderLayout = () => {
    switch (layoutType) {
      case 'withSidebar':
        return (
          <div className="min-h-screen flex flex-col">
            <Header />
            <div className="flex flex-1 overflow-hidden h-[calc(100vh-60px)]">
              <Sidebar />
              <div className="flex-1 flex h-[calc(100vh-60px)]">{children}</div>
            </div>
          </div>
        )
      default:
        return children
    }
  }

  return renderLayout()
}
